<template>
  <div>
    <div></div>
    <div :class="flag ? 'header-show' : 'header-hidden'" v-show="true">
      <div class="goback" @click="goback"><van-icon name="arrow-left" /></div>
      <div class="header-title">{{ list.title }}</div>
    </div>
    <div class="pic"><img :src="list.pic" :alt="list.title" /></div>
    <div class="detalmsg">
      <span class="title">{{ list.title }}</span>
      <div class="type">概述：{{ list.slogo }}</div>
          <div class="type">类型：{{ list.labels[2] }}</div>
          <div class="type">上映时间：{{ list.raiting }}</div>
    </div>
    <div class="footer">
      <a href="#">选座购票</a>
    </div>
  </div>
</template>

<script>
export default {
  name: 'film',
  data() {
    return {
      list: {},
      flag: false,
      top: '',
    }
  },
  created() {
    this.$http.get(`/films/${this.$route.query.url}`).then((res) => {
      var lists = res.result
      this.list = lists.find((i) => (i.title == this.$route.query.title))
      console.log(this.list)
      
    })
  },
  // 获取浏览器滚轮
  mounted() {
    window.addEventListener('scroll', () => {
      this.top =
        document.documentElement.scrollTop ||
        document.body.scrollTop ||
        window.pageYOffset
      console.log(this.top)
      if (this.top) {
        this.flag = true
      } else {
        this.flag = false
      }
    })
  },
  methods: {
    goback() {
      // history.back()
      this.$router.push('/')
    },
  },
}
</script>
<style>
.header-show {
  transition: background-color 1s;
  -moz-transition: background-color 1s; /* Firefox 4 */
  -webkit-transition: background-color 1s; /* Safari 和 Chrome */
  -o-transition: background-color 1s; /* Opera */

  position: fixed;
  background-color: rgb(255, 255, 255);
  color: #191a1b;
  width: 100vw;
  height: 44px;
  z-index: 1;
}
.header-hidden {
  transition: background-color 0.5s;
  -moz-transition: background-color 0.5s; /* Firefox 4 */
  -webkit-transition: background-color 0.5s; /* Safari 和 Chrome */
  -o-transition: background-color 0.5s; /* Opera */

  background-color: rgba(255, 255, 255, 0);
  color: rgba(255, 255, 255, 0);
  position: fixed;
  width: 100vw;
  height: 44px;
  z-index: 1;
}
.goback {
  position: fixed;
  top: 4px;
  left: 11px;
  width: 35px;
  height: 35px;
  background-color: rgba(255, 255, 255, 0.5);
  padding-top: 5px;
  padding-left: 4px;
  color: #191a1b;
  box-sizing: border-box;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  z-index: 2;
}
.header-title {
  position: fixed;
  font-size: 17px;
  line-height: 44px;
  width: 100vw;
  text-align: center;
}
.pic {
  width: 100%;
  height:100vh;
  /* background-color: #fff; */
  overflow: hidden
}
.pic img {
  display: inline-block;
  width: 100%;
  /* 截取下50% */
   transition: translateY(-50%);
  /* -webkit-transform: translateY(-50%);  */
}
.detalmsg{
  position: absolute;
  top:100%;
  width: 100%;
  height: 200px;
  padding:20px;
  background-color: #fff;
  box-sizing: border-box;
}
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  height: 49px;
  width: 100vw;
  text-align: center;
  background-color: #ff5f16;
  color: #fff;
  font-size: 16px;
  line-height: 49px;
}
.footer a {
  display: inline-block;
  width: 100%;
  /* background-color: rgba(255, 255, 255, 0.5); */
  text-decoration: none;
  color: #fff;
}
</style>
